package com.ss.android.article.browser.view.a;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.browser.R;

public final class WebSiteGridView {
    public View mRoot;
    public TextView b;
    public com.ss.android.article.browser.view.a.b c;
    public int d;
    public boolean e;
    private RecyclerView f;
    private GridLayoutManager g;

    public WebSiteGridView(Context context) {
        this.mRoot = View.inflate(context, R.layout.e0, null);
        this.f = this.mRoot.findViewById(com.ss.android.article.browser.R.id.w1);
        this.mRoot.findViewById(com.ss.android.article.browser.R.id.w0);
        this.b = this.mRoot.findViewById(com.ss.android.article.browser.R.id.tv_search_box);
        this.d = UIUtils.getScreenWidth(context);
        this.c = new b();
        this.g = new GridLayoutManager(context, 4);
        this.f.setAdapter(this.c);
        this.f.setLayoutManager(this.g);
        this.f.addItemDecoration(new a(1));
    }

    public final void setVisible(boolean visible) {
        mRoot.setVisibility(visible ? View.VISIBLE : View.GONE);
    }

    public final void a() {
        ObjectAnimator translationXAnimator = ObjectAnimator.ofFloat(this.mRoot, "translationX", new float[]{0f, ((float) this.d)});
        translationXAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
        translationXAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public final void onAnimationEnd(Animator animator) {
                WebSiteGridView.this.b();
            }
        });
        translationXAnimator.setDuration(200).start();
    }

    public final void b() {
        if (this.mRoot != null) {
            if (this.mRoot.getParent() != null && ((this.mRoot.getParent() instanceof ViewGroup))) {
                ((ViewGroup) this.mRoot.getParent()).removeView(this.mRoot);
            }
            this.mRoot.clearAnimation();
        }
    }

    public final boolean c() {
        boolean v0 = true;
        if (this.mRoot == null) {
            label_14:
            v0 = false;
        } else if (this.mRoot.isShown()) {
            this.e = true;
            this.a();
        } else if (this.mRoot.getParent() != null) {
            this.setVisible(true);
        } else {
            return false;
        }

        return v0;
    }
}

